// 路由注册页面
const routerList = [
  {
    path: "/adminHome",
    component: () => import("@/views/admin/adminHome/index.vue"),
    name: "adminHome",
    meta: {
      title: "后台主页",
    },
  },
  {
    path: "/menuManage",
    component: () => import("@/views/admin/menuManage/index.vue"),
    name: "MenuManage",
    meta: {
      title: "菜单管理",
    },
  },
  {
    path: "/menuList",
    component: () => import("@/views/admin/menuManage/menuList.vue"),
    name: "MenuList",
    meta: {
      title: "菜单列表",
    },
  },
  {
    path: "/systemSettings",
    name: "SystemSettings",
    meta: {
      title: "系统设置",
    },
    children: [
      {
        path: "/systemSettings/accountManage",
        component: () =>
          import("@/views/admin/systemSettings/accountManage/index.vue"),
        name: "AccountManage",
        meta: {
          title: "账号管理",
          keepAlive: true,
        },
      },
      {
        path: "/systemSettings/departmentManage",
        component: () =>
          import("@/views/admin/systemSettings/departmentManage/index.vue"),
        name: "DepartmentManage",
        meta: {
          title: "部门管理",
        },
      },
      {
        path: "/systemSettings/rolesManage",
        component: () =>
          import("@/views/admin/systemSettings/rolesManage/index.vue"),
        name: "RolesManage",
        meta: {
          title: "角色管理",
        },
      },
    ],
  },

  {
    path: "/codeDictionary",
    component: () => import("@/views/admin/codeDictionary/index.vue"),
    name: "CodeDictionary",
    meta: {
      title: "代码词典",
      keepAlive: true,
    },
  },
];

const adminList = getChildren(routerList);
// 遍历数组 把children里面的数据都遍历到第一级 children 层级不确定
function getChildren(arr) {
  let children = [];
  arr.forEach((item) => {
    if (!item.children) {
      children.push(item);
    }
    if (item.children) {
      children = children.concat(getChildren(item.children));
    }
  });
  return children;
}

export { adminList };
